import { useRequest } from "../../../utils/request";
import { bindUserInfo, getUserInfo } from "../../../service/user";
import { uploadImage } from "../../../utils/utils";

Component({
    properties: {},
    data: {},
    methods: {
        onLoad() {
            bindUserInfo(this)

            this.editUserRequest = new useRequest('api/edituserinfo', {
                hold: true
            }, this)
        },
        async changeAvatar() {
            const avatar = await uploadImage()
            await this.editUserRequest.run({ avatar: avatar[0] })
            await getUserInfo()
        },
    }
});
